import { Platformsort } from '@/modules/businessModule/platformsort/assets/platformsort.entity';
import { Product } from '@/modules/businessModule/product/assets/product.entity';
import { SpecsType } from '@/modules/businessModule/specsType/assets/specsType.entity';
import { ApiProperty } from '@nestjs/swagger';
import { Column, Entity, JoinTable, ManyToMany, OneToMany, PrimaryGeneratedColumn } from 'typeorm';

@Entity()
export class Platform {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  @ApiProperty({ description: '商品名称' })
  platFormName: string;

  @Column()
  @ApiProperty({ description: '商品标签' })
  tags: string;

  @Column()
  @ApiProperty({ description: '商品图片' })
  productImgs: string;

  @Column()
  @ApiProperty({ description: '商品介绍' })
  introduce: string;

  @Column()
  @ApiProperty({ description: '商品详情' })
  goodDetail: string;

  @Column()
  @ApiProperty({ description: '销售量' })
  hasSell: number;

  @Column({ default: false })
  @ApiProperty({ default: false, description: '状态' })
  status: boolean;

  @Column()
  @ApiProperty({ description: '商品logo' })
  platFormLogo: string;

  @Column({ default: true })
  @ApiProperty({ default: true, description: '是否推荐' })
  isRecommod: boolean;

  @ManyToMany(() => Platformsort)
  @JoinTable({ name: 'platform_platformsort' })
  @ApiProperty({
    description: '商品分类',
    type: () => Platformsort,
  })
  platformsort: Platformsort[];

  @OneToMany(() => SpecsType, (specsType) => specsType.platForm)
  @ApiProperty({ description: '规格类型', type: () => SpecsType })
  specsType: SpecsType[];

  @OneToMany(() => Product, (product) => product.platform)
  @ApiProperty({ description: '规格', type: () => Product })
  product: Product[];
}
